using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Identity.Settings;
using Volo.Abp.Localization;
using Volo.Abp.SettingManagement;
using Volo.Abp.Uow;

namespace Vm.SystemManager.Domain.IdentityServer
{
    public class IdentityDataSeedContributor : IDataSeedContributor, ITransientDependency
    {
        private readonly ISettingManager _settingManager;

        public IdentityDataSeedContributor(ISettingManager settingManager)
        {
            _settingManager = settingManager;
        }

        [UnitOfWork]
        public virtual async Task SeedAsync(DataSeedContext context)
        {
            await _settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequiredLength, "1");
            await _settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequiredUniqueChars, "1");
            await _settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequireNonAlphanumeric, "false");
            await _settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequireLowercase, "false");
            await _settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequireUppercase, "false");
            await _settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequireDigit, "false");

            await _settingManager.SetGlobalAsync(LocalizationSettingNames.DefaultLanguage, "zh-Hans");
        }
    }
}
